package mx.com.switz.utils.mail;

import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.mail.javamail.MimeMessageHelper;



public class MailMail {




    private JavaMailSenderImpl  mailSender;
    public MailMail(){
    	
    }

    public void setMailSender(JavaMailSenderImpl  mailSender) {
        this.mailSender = mailSender;
    }

    public JavaMailSenderImpl  getMailSender() {
        return mailSender;
    }

    public void sendMail(String to, String subject, String msg) {
        try {
            MimeMessage message = mailSender.createMimeMessage();
            MimeMessageHelper helper = new MimeMessageHelper(message, true);
            helper.setFrom("chustga@gmail.com");
            helper.setTo(to);
            helper.setSubject(subject);
            helper.setText(msg, true);
            
            mailSender.send(message);


              //   MimeMessageHelper helper = new MimeMessageHelper(message, true);

     //        SimpleMailMessage message = new SimpleMailMessage();

           //  message.setFrom("japs8704@gmail.com");
     //        message.setTo(to);
     //        message.setSubject(subject);
     //        message.setText(msg);
     //       
     //        mailSender.send(message);
           //  message = getMailSender().createMimeMessage();
        } catch (MessagingException ex) {
            Logger.getLogger(MailMail.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
